import numpy as np
import random as rm
import matplotlib.pyplot as plt

''' 生成一个随机>0的[x1-x2]，长度为L1的线段 '''


def getLineRandom(L1):
    '''
    生成一个区间，区间的长度为：L1
    随机构造一个线段 |_________|
    :param L1:
    :return:
    '''
    add = round(rm.random(), 4)
    sub = round(add - L1, 4)
    while sub < 0:
        add = round(rm.random(), 4)
        sub = round(add - L1, 4)
    line = []
    line.append(sub)
    line.append(add)
    return line


''' 应该是生成了两个区间，[x1,x2,y1,y2] 每个区间的长度都为l1，l2 '''


def getRondomIVq_ROF(L1, L2):
    '''
    任意区间值广义正交模糊数
    :param L1:U部分长度
    :param L2:V部分长度
    :return:
    '''
    U = getLineRandom(L1)
    V = getLineRandom(L2)
    IVq_ROF = []
    IVq_ROF.append(U)
    IVq_ROF.append(V)
    return IVq_ROF


'''
第1个案例
  L1=L2=L3=L4=0
'''


def getZeroRandomIVq_ROF():
    '''
    隶属度和非隶属度不是区间值的，即广义正交模糊数
                  *
                   <-- *
    :return:
    '''
    L1 = 0
    L2 = 0
    L3 = 0
    L4 = 0
    Case = []
    U = getLineRandom(L1)
    while U[0] <= 0.2 or U[0] >= 0.75:
        U = getLineRandom(L1)
    # print(U[0])
    for i in range(-5, 5):
        mycase = []
        temp = round((U[0] - i * 0.05), 4)
        V = [temp, temp]
        a1 = [U, U]
        a2 = [V, V]
        mycase.append(a1)
        mycase.append(a2)
        Case.append(mycase)

    return Case


'''
第2个案例
'''


def getequalallnozerorcase():
    '''
    L1=L2=L3=L4且不等于0，其中a2从左往右移动
    |__________|
            <----           |___________|
    :return:
    '''
    Case = []
    a1 = [[0.6, 0.7], [0.5, 0.6]]
    a2 = [[0.75, 0.85], [0.7, 0.8]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)

    c1 = 0.75
    c2 = 0.85
    for i in range(1, 15):

        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.7
        v2 = 0.8
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第3个测试案例

'''


def getL1eqL3L2eqL4case():
    '''
    |__________|                               |______|
            <----           |___________|                |______|
       L1=L3, L2=L4 且都不等于0

       :return:
       '''
    Case = []
    a1 = [[0.6, 0.7], [0.3, 0.35]]
    a2 = [[0.75, 0.85], [0.6, 0.65]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)
    c1 = 0.75
    c2 = 0.85
    for i in range(1, 15):
        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.6
        v2 = 0.65
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第4个案例

'''


def getL1eqL3L2noeqL4case():
    '''
       L1=L3，L2=L4
       且不等于0，其中a2从左往右移动
         |____________________|                     |___________|
            <----               |___________|      |___________|
       :return:
       '''
    Case = []
    a1 = [[0.6, 0.7], [0.3, 0.35]]
    a2 = [[0.75, 0.85], [0.6, 0.7]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)

    c1 = 0.75
    c2 = 0.85
    for i in range(1, 15):

        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.6
        v2 = 0.7
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第5个案例

'''


def getL1bigerL3L2eqL4case():
    '''
    L1>L3, L2=L4
    S1=S2且不等于0，
    其中a2从左往右移动
         |_____________|                     |___________|
            <----        |___________|                        |___________|
    :return:
    '''
    Case = []
    a1 = [[0.6, 0.7], [0.3, 0.35]]
    a2 = [[0.75, 0.80], [0.6, 0.65]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)

    c1 = 0.75
    c2 = 0.80
    for i in range(1, 15):

        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.6
        v2 = 0.65
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第6个案例

'''


def getL1bigerL3L2bigerL4case():
    '''
          L1>L3，L2>L4且不等于0，其中a2从左往右移动
          你可以画两条线段，按照下面方式从右往左移动，得到下面的案例
                  |_________________|  (U)               |____________________| (V)
            <----        |___________|                        |___________|
          :return:
          '''
    Case = []
    a1 = [[0.6, 0.7], [0.3, 0.4]]
    a2 = [[0.75, 0.80], [0.6, 0.65]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)

    c1 = 0.75
    c2 = 0.80
    for i in range(1, 15):
        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.6
        v2 = 0.65
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第7个案例

'''


def getL1bigerL3L2litterL4case():
    '''
          L1>L3，L2>L4且不等于0，其中a2从左往右移动
          你可以画两条线段，按照下面方式从右往左移动，得到下面的案例
                  |_________________|  (U)               |____________________| (V)
            <----        |___________|                        |___________|
          :return:
          '''
    Case = []
    a1 = [[0.6, 0.7], [0.3, 0.35]]
    a2 = [[0.75, 0.80], [0.6, 0.7]]
    case1 = []
    case1.append(a1)
    case1.append(a2)
    Case.append(case1)

    c1 = 0.75
    c2 = 0.80
    for i in range(1, 15):

        c1 = round(c1 - 0.05, 3)
        c2 = round(c2 - 0.05, 3)
        temp = [c1, c2]
        v1 = 0.6
        v2 = 0.7
        for j in range(9):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


''' 案例8  '''


def li_data():
    data = [
        [([0.30, 0.50], [0.20, 0.40]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.20, 0.20], [0.30, 0.30]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.50, 0.60], [0.30, 0.40]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.35, 0.45], [0.20, 0.30]), ([0.30, 0.50], [0.15, 0.35])],
        [([0.30, 0.30], [0.30, 0.30]), ([0.40, 0.40], [0.40, 0.40])],
        [([0.00, 0.00], [0.10, 0.10]), ([0.00, 0.00], [0.90, 0.90])],
        [([0.00, 0.00], [0.20, 0.20]), ([0.00, 0.00], [0.30, 0.30])],
        [([0.30, 0.50], [0.30, 0.50]), ([0.40, 0.50], [0.40, 0.50])],
        [([0.10, 0.10], [0.10, 0.10]), ([0.40, 0.50], [0.40, 0.50])],
        [([0.30, 0.40], [0.20, 0.40]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.50, 0.50], [0.50, 0.50]), ([0.30, 0.50], [0.30, 0.50])],
        [([0.15, 0.50], [0.03, 0.50]), ([0.18, 0.50], [0.06, 0.50])],
        [([0.20, 0.20], [0.20, 0.20]), ([0.30, 0.30], [0.10, 0.10])],
        [([0.10, 0.40], [0.20, 0.50]), ([0.20, 0.30], [0.30, 0.40])],
        [([0.20, 0.40], [0.30, 0.40]), ([0.10, 0.50], [0.20, 0.50])],
        [([0.30, 0.60], [0.20, 0.30]), ([0.40, 0.50], [0.10, 0.40])],
        [([0.20, 0.60], [0.20, 0.40]), ([0.30, 0.50], [0.10, 0.50])],  # Rıdvan ¸Sahin 2015
        [([0.40, 0.40], [0.60, 0.60]), ([0.30, 0.30], [0.50, 0.50])],
        [([0.40, 0.40], [0.40, 0.40]), ([0.50, 0.50], [0.50, 0.50])],
        [([0.00, 0.00], [0.00, 0.00]), ([0.00, 0.00], [0.50, 0.50])],
        [([1.00, 1.00], [0.00, 0.00]), ([0.00, 0.00], [1.00, 1.00])],
        [([1.00, 1.00], [0.00, 0.00]), ([0.00, 0.00], [0.50, 0.50])],  # Hoang Nguyen
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([0.2, 0.2], [0.55, 0.55]), ([0.05, 0.05], [0.2, 0.2])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.6, 0.7], [0.3, 0.35])],
        [([1 / 6, 1 / 2], [0, 1 / 12])], [([1 / 4, 5 / 12], [0, 1 / 6])],
        [([0.0, 0.0], [0.2, 0.2]), ([0.0, 0.0], [0.3, 0.3])],
        [([0.3, 0.3], [0.3, 0.3]), ([0.4, 0.4], [0.4, 0.4])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([0.0, 0.0], [0.2, 0.2]), ([0.0, 0.0], [0.3, 0.3])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([0.0, 0.0], [0.2, 0.2]), ([0.0, 0.0], [0.3, 0.3])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([0.0, 0.0], [0.2, 0.2]), ([0.0, 0.0], [0.3, 0.3])],
        [([0.2, 0.2], [0.3, 0.3]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.5, 0.55], [0.15, 0.25])],
        [([0.05, 0.05], [0.1, 0.1]), ([0.75, 0.75], [0.5, 0.5])],
        [([0.05, 0.05], [0.1, 0.1]), ([0.85, 0.85], [0.7, 0.7])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.3, 0.3], [0.3, 0.3]), ([0.4, 0.4], [0.4, 0.4])],
        [([0.3, 0.6], [0.2, 0.3]), ([0.4, 0.5], [0.1, 0.4])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.3, 0.3], [0.3, 0.3]), ([0.4, 0.4], [0.4, 0.4])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.85, 0.85], [1.0, 1.0]), ([0.75, 0.75], [1.0, 1.0])],
        [([0.65, 0.65], [1.0, 1.0]), ([0.95, 0.95], [1.0, 1.0])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.1, 0.4], [0.2, 0.5]), ([0.2, 0.3], [0.3, 0.4])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.5, 0.6], [0.2, 0.25])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.6, 0.7], [0.3, 0.35])],
        [([0.2, 0.2], [0.3, 0.3]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.9, 0.9], [0.0, 0.0]), ([0.85, 0.85], [0.15, 0.15])],
        [([0.75, 0.75], [0.2, 0.2]), ([0.8, 0.8], [0.05, 0.05])],
        [([0.4, 0.6], [0.3, 0.7]), ([0.3, 0.7], [0.4, 0.6])],
        [([0.4, 0.4], [0.4, 0.4]), ([0.5, 0.5], [0.5, 0.5])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.6, 0.7], [0.3, 0.35])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.3, 0.3], [0.9, 0.9]), ([0.05, 0.05], [0.4, 0.4])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.2, 0.6], [0.2, 0.4]), ([0.3, 0.5], [0.1, 0.5])],
        [([0.1, 0.4], [0.2, 0.5]), ([0.2, 0.3], [0.3, 0.4])],
        [([0.0, 0.0], [0.0, 0.0]), ([0.0, 0.0], [0.5, 0.5])],
        [([0.3, 0.4], [0.2, 0.4]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.05, 0.15], [0.15, 0.25])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.1, 0.15], [0.2, 0.3])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.3, 0.4], [0.2, 0.4]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.3, 0.6], [0.2, 0.3]), ([0.4, 0.5], [0.1, 0.4])],
        [([0.1, 0.4], [0.2, 0.5]), ([0.2, 0.3], [0.3, 0.4])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.2, 0.6], [0.2, 0.4]), ([0.3, 0.5], [0.1, 0.5])],
        [([0.4, 0.4], [0.4, 0.4]), ([0.5, 0.5], [0.5, 0.5])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.2, 0.2], [0.3, 0.3]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.6, 0.7], [0.3, 0.35]), ([0.35, 0.4], [0.25, 0.35])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.4, 0.4], [0.6, 0.6]), ([0.3, 0.3], [0.5, 0.5])],
        [([0.3, 0.6], [0.2, 0.3]), ([0.4, 0.5], [0.1, 0.4])],
        [([0.8, 0.8], [0.1, 0.1]), ([0.1, 0.1], [0.8, 0.8])],
        [([0.55, 0.55], [0.05, 0.05]), ([0.2, 0.2], [0.45, 0.45])],
        [([0.65, 0.65], [0.7, 0.7]), ([0.5, 0.5], [0.85, 0.85])],
        [([0.5, 0.5], [0.25, 0.25]), ([0.1, 0.1], [0.65, 0.65])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.3, 0.4], [0.2, 0.4]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.1, 0.1], [0.1, 0.1]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.3, 0.4], [0.2, 0.4]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.1, 0.4], [0.2, 0.5]), ([0.2, 0.3], [0.3, 0.4])],
        [([0.2, 0.4], [0.3, 0.4]), ([0.1, 0.5], [0.2, 0.5])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([0.0, 0.0], [0.2, 0.2]), ([0.0, 0.0], [0.3, 0.3])],
        [([0.0, 0.0], [0.0, 0.0]), ([0.0, 0.0], [0.5, 0.5])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.2, 0.2], [0.3, 0.3]), ([0.25, 0.25], [0.35, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.4413, 0.9313], [0.0919, 0.9219]), ([0.1592, 0.6492], [0.0463, 0.8763])],
        [([0.1894, 0.6794], [0.03, 0.86]), ([0.4972, 0.9872], [0.0853, 0.9153])],
        [([0.4446, 0.9346], [0.0346, 0.8646]), ([0.0267, 0.5167], [0.0358, 0.8658])],
        [([0.2, 0.2], [0.2, 0.2]), ([0.3, 0.3], [0.1, 0.1])],
        [([0.3, 0.6], [0.2, 0.3]), ([0.4, 0.5], [0.1, 0.4])],
        [([0.2, 0.6], [0.2, 0.4]), ([0.3, 0.5], [0.1, 0.5])],
        [([0.0191, 0.8891], [0.1931, 0.6131]), ([0.0454, 0.9154], [0.2999, 0.7199])],
        [([0.0519, 0.9219], [0.0647, 0.4847]), ([0.0599, 0.9299], [0.5557, 0.9757])],
        [([0.0545, 0.9245], [0.3568, 0.7768]), ([0.0303, 0.9003], [0.2583, 0.6783])],
        [([0.0585, 0.9785], [0.416, 0.726]), ([0.0058, 0.9258], [0.2083, 0.5183])],
        [([0.0491, 0.9691], [0.3337, 0.6437]), ([0.0015, 0.9215], [0.4109, 0.7209])],
        [([0.0291, 0.9491], [0.3312, 0.6412]), ([0.0534, 0.9734], [0.4281, 0.7381])],
        [([0.0, 0.0], [0.1, 0.1]), ([0.0, 0.0], [0.9, 0.9])],
        [([1.0, 1.0], [0.0, 0.0]), ([0.0, 0.0], [1.0, 1.0])],
        [([0.3, 0.5], [0.2, 0.4]), ([0.35, 0.45], [0.25, 0.35])],
        [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])],
        [([0.3, 0.3], [0.3, 0.3]), ([0.4, 0.4], [0.4, 0.4])],
        [([0.3, 0.5], [0.3, 0.5]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.1, 0.1], [0.1, 0.1]), ([0.4, 0.5], [0.4, 0.5])],
        [([0.3, 0.4], [0.2, 0.4]), ([0.35, 0.35], [0.25, 0.35])],
        [([0.0036, 0.9136], [0.0299, 0.5299]), ([0.0474, 0.9574], [0.0876, 0.5876])],
        [([0.0035, 0.9135], [0.2478, 0.7478]), ([0.0449, 0.9549], [0.2562, 0.7562])],
        [([0.5, 0.5], [0.5, 0.5]), ([0.3, 0.5], [0.3, 0.5])],
        [([0.15, 0.5], [0.03, 0.5]), ([0.18, 0.5], [0.06, 0.5])],
        [([0.1, 0.4], [0.2, 0.5]), ([0.2, 0.3], [0.3, 0.4])]
    ]
    return data


'''
第9个案例
'''


def RandomCase():
    Case = []
    for j in range(10):
        L1 = round(rm.random(), 2)
        L2 = round(rm.random(), 2)
        for i in range(100):
            mycase = []
            a1 = getRondomIVq_ROF(L1, L2)
            a2 = getRondomIVq_ROF(L1, L2)
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第10个案例
'''


def getstopRandomCase():
    '''
    谷底那个一个点，这个点在中点，另外一个点从右往左移动
    :return:
    '''
    Case = []
    a1 = ([0.50, 0.50], [0.50, 0.50])
    c1 = 1.00
    c2 = 1.00
    for i in range(1, 10):

        c1 = round(c1 - 0.1, 3)
        c2 = round(c2 - 0.1, 3)
        temp = [c1, c2]
        v1 = 1.00
        v2 = 1.00
        for j in range(10):
            mycase = []
            v1 = round(v1 - 0.1, 3)
            v2 = round(v2 - 0.1, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    print("Case12:")
    for i in range(len(Case)):
        print(Case[i])
    return Case


'''
第11个案例
'''


def getStopEndRandomCase():
    '''
    固定一个点，这个点在端点，另一个点从右向左移动
    :return:
    '''
    Case = []
    a1 = ([1.00, 1.00], [0.00, 0.00])
    c1 = 0.00
    c2 = 0.00
    for i in range(1, 20):
        c1 = round(c1 + 0.05, 3)
        c2 = round(c2 + 0.05, 3)
        temp = [c1, c2]
        v1 = 1.00
        v2 = 1.00
        for j in range(1, 20):
            mycase = []
            v1 = round(v1 - 0.05, 3)
            v2 = round(v2 - 0.05, 3)
            V = [v1, v2]
            a2 = [temp, V]
            mycase.append(a1)
            mycase.append(a2)
            Case.append(mycase)
    return Case


'''
第12个案例
'''


def getL1eqlL2L3eqL4Case():
    '''
        L1 = l2, l3 = l4但 l1 != l3
        :return:
        '''
    Case = []
    c1 = 0.00
    c2 = 0.00
    c3 = 0.00
    c4 = 0.00
    # Case.append([([c1, c1],[c2, c2]), ([c3, c3], [c4, c4])])
    for i in range(20):
        c1 = round(c1 + 0.05, 2)
        temp1 = [c1, c1]
        c2 = 0
        for j in range(20):
            c2 = round(c2 + 0.05, 2)
            if c1 == c2:
                continue
            temp2 = [c2, c2]
            c3 = 0
            for k in range(20):
                c3 = round(c3 + 0.05, 2)
                temp3 = [c3, c3]
                c4 = 0
                for q in range(20):
                    c4 = round(c4 + 0.05, 2)
                    if c3 == c4 or (c1 == c3 and c2 == c4):
                        continue
                    temp4 = [c4, c4]
                    Case.append([(temp1, temp2), (temp3, temp4)])

    return Case


'''
第15个案例
'''


# num为最后Case的数据规模, 默认100, 控制数据规模改变num的默认值，或者传入该函数一个数值代表数据规模即可
def getL1eqlL2L3eqL4Case_1(num=1000):
    '''
        L1 = l2, l3 = l4但 l1 != l3
        :return:
        '''
    arr = [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95]
    Case = []
    while len(Case) != num:
        c1 = rm.choice(arr)
        c2 = rm.choice(arr)
        c3 = rm.choice(arr)
        c4 = rm.choice(arr)
        if c1 == c2 or c3 == c4 or (c1 == c3 and c2 == c4):
            continue
        else:
            temp = [([c1, c1], [c2, c2]), ([c3, c3], [c4, c4])]
            if temp not in Case:
                # 这里是舍弃重复的数据, 不重复才加入结果集里
                Case.append(temp)

    return Case


'''
第16个案例
'''


def getL1randomL2L3eqL4Case(num=1000):
    '''
    随机排列的(备用测试集)
    :return:
    '''
    arr = [0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2,
           0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4,
           0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6,
           0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8,
           0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1.0]
    Case = []
    while len(Case) != num:
        c1 = rm.choice(arr)
        c2 = rm.choice(arr)
        c3 = rm.choice(arr)
        c4 = rm.choice(arr)
        c5 = rm.choice(arr)
        c6 = rm.choice(arr)
        c7 = rm.choice(arr)
        c8 = rm.choice(arr)
        temp = [([c1, c2], [c3, c4]), ([c5, c6], [c7, c8])]
        if temp not in Case:
            # 这里是舍弃重复的数据, 不重复才加入结果集里
            Case.append(temp)

    return Case


if __name__ == "__main__":

    case = getL1randomL2L3eqL4Case()

    for i in range(len(case)):
        print(case[i])
    print(len(case))
    # pass
    # case=getstopRandomCase()
    # case = RandomCase()
    # for i in range(len(case)):
    #    print(case[i])
